package com.mybar.subject.common.entity;

import com.mybar.subject.common.enums.ResultCodeEnums;
import lombok.Data;

@Data
public class Result<T> {

    private Boolean success;

    private Integer code;

    private String message;

    private T data;

    public static <T>Result ok( ){
        Result result =new Result();
        result.setSuccess(true);
        result.setCode(ResultCodeEnums.SUCCESS.getCode());
        result.setMessage(ResultCodeEnums.SUCCESS.getDesc());
        return result;

    }
    public static <T>Result ok(T data){
        Result result =new Result();
        result.setSuccess(true);
        result.setCode(ResultCodeEnums.SUCCESS.getCode());
        result.setMessage(ResultCodeEnums.SUCCESS.getDesc());
        result.setData(data);
        return result;

    }

    public static <T>Result fail(){
        Result result =new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeEnums.FAIL.getCode());
        result.setMessage(ResultCodeEnums.FAIL.getDesc());
        return result;

    }
    public static <T>Result fail(T data){
        Result result =new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeEnums.FAIL.getCode());
        result.setMessage(ResultCodeEnums.FAIL.getDesc());
        result.setData(data);
        return result;

    }

}
